/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbean;

import entity.RedemptionListEntity;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import org.primefaces.event.SelectEvent;
import session.stateful.RedemptionSessionBean;

@ManagedBean(name = "redemptionManagerBean")
@SessionScoped
public class RedemptionManagerBean {

    @EJB
    RedemptionSessionBean redemptionSessionBean;
    private RedemptionListEntity selectedRedemptionList;
    private RedemptionListEntity redemptionList;
    private List<RedemptionListEntity> listOfRedemptionList = new ArrayList<RedemptionListEntity>();

    public RedemptionManagerBean() {
        selectedRedemptionList = new RedemptionListEntity();
        redemptionList = new RedemptionListEntity();
    }

    public void addRedemptionList() {
        redemptionSessionBean.addRedemptionList(redemptionList);
        redemptionList = new RedemptionListEntity();
    }

    public void editRedemptionList() {
        redemptionSessionBean.editRedemptionList(selectedRedemptionList);
    }

    public void initListOfRedemptionList(PhaseEvent event) {
        listOfRedemptionList = redemptionSessionBean.getAllRedemptionList();
    }

    public String onRowSelectNavigateRedemptionList(SelectEvent event) {
        FacesContext.getCurrentInstance().getExternalContext().getFlash().put("selectedRedemptionList", event.getObject());
        return "staff/TCubeEditRedemptionListInfo?faces-redirect=true";
    }

    public List<RedemptionListEntity> getListOfRedemptionList() {
        return listOfRedemptionList;
    }
    
   public void setListOfRedemptionList(List<RedemptionListEntity> listOfRedemptionList) {
        this.listOfRedemptionList = listOfRedemptionList;
    }
   
    public RedemptionListEntity getSelectedRedemptionList() {
        return selectedRedemptionList;
    }

    public void setSelectedRedemptionList(RedemptionListEntity selectedRedemptionList) {
        this.selectedRedemptionList = selectedRedemptionList;
    }

    public RedemptionListEntity getRedemptionList() {
        return redemptionList;
    }

    public void setRedemptionList(RedemptionListEntity redemptionList) {
        this.redemptionList = redemptionList;
    }
}
